/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package backing;

import java.util.List;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import model.CurrentUser;
import officeboost.domain.OfficeMgr;
import officeboost.domain.TaskInfo;
import officeboost.domain.TaskPack;
import officeboost.entity.form.LeaveForm;

/**
 *
 * @author XJ
 */
@ManagedBean
public class TaskListBacking extends AbstractBacking{
    InfoBacking infoBacking;
    @EJB
    private OfficeMgr officeMgr; 
    private List<TaskInfo> taskList; 
    public TaskListBacking() {
    }

    public List<TaskInfo> getTaskList() {
        return taskList;
    }

    public void setTaskList(List<TaskInfo> taskList) {
        this.taskList = taskList;
    }
    
    public String taskTo(String taskId){
        String outcome="leave_form";
         CurrentUser cu = (CurrentUser) getSessionMap().get("currentUser");
         TaskPack taskpack = officeMgr.getTask(taskId, cu.getUsername());
           
        if(taskpack.getTaskInfo().getFormType().equals("LeaveForm"))
            outcome="leave_form";
        if(taskpack.getTaskInfo().getFormType().equals("LectureForm"))
            outcome="lecture_form";
        
            return outcome;
    }
    
    public void init(){
        CurrentUser cu=(CurrentUser)getSessionMap().get("currentUser");
    //    User user=personService.find(cu.getUsername());
        
        if(officeMgr.getTaskList(cu.getUsername())!=null)
            this.setTaskList(officeMgr.getTaskList(cu.getUsername()));
    }
}
